import React, { useState, useEffect } from 'react'

function App() {
  const [ proList, setProList ] = useState([])
  // useEffect 可以拥有第二个参数
  // useEffect(() => {}, []) ---- componentDidMount --- 关键点 就是 空数组
  // useEffect(() => {}, [id]) ---- id字段变化时才会重新执行
  useEffect(() => {
    fetch('http://121.89.205.189/api/pro/list').then(res => res.json())
      .then(res => {
        console.log(res.data)
        setProList(res.data)
      })
  }, [])

  return (
    <div>
      {
        proList && proList.map(item => {
          return (
          <div key = { item.proid }>{ item.proname }</div>
          )
        })
      }
    </div>
  )
}

export default App
